import React, { Component } from 'react';
import ACTIONS from './../../../redux/action';
import { connect } from 'react-redux/es/exports';


class DigitButton extends Component {
    state = {  } 
    render() { 
        return (
            <React.Fragment>
                {/* 点一下传对应数字 */}
                <button onClick={()=> {
                    return this.props.add_digit(this.props.digit)
                }}>{this.props.digit}</button>
            </React.Fragment>
        );
    }
}


const mapDispatchToProps = {
    add_digit: digit => {
        return{
            type: ACTIONS.ADD_DIGIT,
            digit: digit,
        }
    }
}

export default connect(null, mapDispatchToProps)(DigitButton);